/*
 * Copyright 2008 CSC Consulting Group under the Apache License, 
 * Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License. You may obtain a copy of the License at 
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
 * law or agreed to in writing, software distributed under the License is 
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific language 
 * governing permissions and limitations under the License.
 */
package com.waw.journal.plugin;

import com.jivesoftware.base.plugin.*;
import com.jivesoftware.base.Log;
import com.jivesoftware.community.event.ProfileEventDispatcher;

/**
 * This class handles the lifecycle methods of the Fitness Journal Plugin.
 * In particular, it registers the UserProfileListener with the ProfileEventDispatcher.
 * This listener handles modifications to the User's Profile.
 * <p>
 * The class also write info messages to the log.
 * @see import com.jivesoftware.community.event.ProfileEventDispatcher;
 * @see UserProfileListener
 */
public class JournalPlugin implements Plugin<JournalPlugin> {
	UserProfileListener profileListener = new UserProfileListener();

	/**
	 * Removes the UserProfileListener from the ProfileeventDispatcher.
	 */
    public void destroyPlugin() {
    	ProfileEventDispatcher.getInstance().removeListener(profileListener);
        Log.info("Journal Plugin exiting.");
    }

	/**
	 * Adds the UserProfileListener to the ProfileEventDispatcher.
	 * 
	 * @param manager The plugin manager
	 * @param pluginData Information about the plugin.
	 */	
	public void initializePlugin(PluginManager manager, PluginMetaData pluginData) {
        Log.info("Journal Plugin initializing.");
        ProfileEventDispatcher.getInstance().addListener(profileListener);
	}
}
